<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>提现管理 </h2>
    </div>

    <div class="cf">
        <!-- <span class=""><h3>平台账户余额：{$account}元</h3></span> -->
        <br/>
        <a class="btn r0" href="__CONTROLLER__/withdraw/type/1">未放款</a>
        <a class="btn r1" href="__CONTROLLER__/withdraw/type/2">已放款</a>
		
		<?php if($_GET['type'] == 1){?>
		<a class="btn r0" href="javascript:void(0);" onclick="batch_psd()">批量放款</a>
		<?php }?>
		
		
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <div class="drop-down">
                    <span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_title($status) eq ''">昵称<else/>{:get_status_title($status)}</if></span>
                    <i class="arrow arrow-down"></i>
                    <ul id="sub-sch-menu" class="nav-list hidden">
                        <li><a href="javascript:;" value="2">昵称</a></li>
                    </ul>
                    </div>
                    <input type="text" name="title" class="search-input"  id="campus" value="{:I('get.name')}" placeholder="请输入姓名">
                    <a class="sch-btn" href="javascript:;" id="search"><i class="btn-search"></i></a>
                </div>
            </div>
    </div>

    <div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                    <tr>
                        <th class="row-selected">
                            <input class="checkbox check-all" type="checkbox">
                        </th>
                        <th>姓名</th>
                        <th>金额</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <volist name="data" id="v">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$v.id}"></td>
                        <td>{$v.uid|getUserMemberName=###}</td>
                        <td>{$v.change}</td>
                        <td>{$v.create_time|date="Y-m-d H:i:s",###}</td>
                        <eq name="v.type" value="1">
                        <td class="fangkuan"style="cursor:pointer" >未放款</td>
                        <input type="hidden" value="{$v.id}">
                        <else/>
                        <td>已放款</td>
                        </eq>
                </volist>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">
            {$page}
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $('.fangkuan').on('click',function(){
            var id = $(this).next('input:hidden').val();
            if(confirm('你确定要放款？')){
            $.ajax({
                url: "{:U('fangkuan')}",
                type: 'POST',
                dataType: 'json',
                data: {id: id},
                success:function(data){
                    layer.msg(data, {
                                time: 2000 //20s后自动关闭
                         },function(){
                            location.reload();
                        });
                }
            })
            }
        });
        $(function() {
            $('.oper').click(function(){
                var mes = $(this).html();
                if (confirm('确定要操作吗？')) {
                    var id = $(this).attr('data');
                    var val = $(this).attr('val');
                    var flag = $(this).attr('flag');
                    $.post('__CONTROLLER__/edit', {'id': id,'val':val, 'flag':flag}, function(msg) {
                        alert(msg);
                        location.reload();
                    });
                }
            });

            //记录按钮默认颜色
            $('.p' + "{$Think.get.passed}").css('background','#0c7dac');

            //搜索功能
            $("#search").click(function() {
                 var status = {$_GET['type']};
                 var name   = $('.search-input').val();
                 window.location.href="__CONTROLLER__/withdraw/type/"+type+"/name/"+name;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });

            //导航高亮
            highlight_subnav('{:U('index')}');

        });
		
		
		
		
			
		/*批量审核*/
		function batch_psd(){
	
			obj = document.getElementsByName("ids[]");
			check_val = [];
			for(k in obj){
				if(obj[k].checked)
					check_val.push(obj[k].value);
			}

			if(check_val == "" || check_val == null){
			
				alert("请选择要操作的数据！");
				return;
			
			}else{
			
		
				
			/*ajax*/
			$.post('__CONTROLLER__/ajaxfangkuan', {'ids': check_val}, function(msg) {
                alert(msg);
                location.reload();
            });

			
			}

		}
		
		
		
		
		
		
		
		
		
		
    </script>
</block>